package com.wuyou.simple;

import java.util.*;

/**
 * 1640. 能否连接形成数组
 */
public class CanFormArray {


    public static void main(String[] args) {

        CanFormArray canFormArray = new CanFormArray();

        int[][] pieces = {{88}, {15}};
        int[] arr = {15, 88};
        System.out.println(canFormArray.solution_2(arr, pieces));
    }



    public boolean solution_2(int[] arr, int[][] pieces){
        List<int[]> list = Arrays.asList(pieces);
        boolean flag = true;
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            map.put(arr[i], i);
        }
        for (int i = 0; i < list.size(); i++) {
            if (map.get(list.get(i)[0]) != null) {
                for (int j = 0; j < arr.length - map.get(list.get(i)[0]) - 1; j++) {

                }
            }
        }
        


        return false;
    }
    public boolean solution_1(int[] arr, int[][] pieces) {

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            list.add(arr[i]);
        }
        for (int i = 0; i < pieces.length; i++) {

            List<Integer> tempList = new ArrayList<>();
            int index = 0;
            for (int j = 0; j < pieces.length; j++) {
                while (j < pieces[i].length && index < arr.length) {
                    if (pieces[i][j] == arr[index]) {
                        tempList.add(index);
                        j++;
                    } else if (j > 0) {
                        break;
                    }
                    index++;
                }
                if (tempList.size() == 0) {
                    break;
                }
            }
            for (int j = 0; j < tempList.size(); j++) {
                arr[tempList.get(j)] = -1;
            }
            tempList.clear();
        }

        for (int i = 0; i < arr.length; i++) {
            if (arr[i] != -1) {
                return false;
            }
        }
        return true;
    }

}
